from baseTools.tool_api import *
from baseTools.tool_readyaml import *
from baseTools.tool_logger import *

def get_token():
    try:
        api_token = MyApi()
        db_read = MyYaml('./baseDate/db_token.yaml')
        data = db_read.token_yaml()
        method = data[0][0]
        url = data[0][1]
        parameter = data[0][2]
        respond = api_token.myrequest(method=method, url=url, params=parameter).json()
        token_value = respond.get('access_token')
        token_param = {'access_token': token_value}
        return token_param
    except Exception as e:
        logger.error('获取token失败，报错信息{}'.format(e))



if __name__ == '__main__':
    print(get_token())